package com.battle.service.controller.web;

import com.battle.pojo.param.healthRecord.*;
import com.battle.pojo.vo.healthRecord.*;
import com.battle.service.service.in.*;
import nirvana.core.domains.vo.PageResult;
import nirvana.core.domains.vo.ApiResult;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;

import java.util.List;

/**
 * web/健康档案
 * 【描 述】：
 * 【环 境】：J2SE
 * 【详 细】：
 */
@RestController
@RequestMapping("/healthRecord/web")
public class HealthRecordWebController {

    private final HealthRecordService service;

    public HealthRecordWebController(HealthRecordService service) {
        this.service = service;
    }


    /**
     * 创建健康档案
     *
     * @param param
     * @return
     */
    @PostMapping("/createHealthRecord")
    public ApiResult createHealthRecord(@RequestBody @Valid CreateHealthRecordParam param) {
        service.createHealthRecord(param);
        return ApiResult.ok();
    }


    /**
     * 修改健康档案
     *
     * @param param
     */
    @PutMapping("/editHealthRecord")
    public ApiResult editHealthRecord(@RequestBody @Valid EditHealthRecordParam param) {
        service.editHealthRecord(param);
        return ApiResult.ok();
    }


    /**
     * 批量更新-数据加密
     * @return
     */
    @PostMapping("/bathUpdate")
    public ApiResult bathUpdate() {
        service.bathUpdate();
        return ApiResult.ok();
    }

    /**
     * 移除健康档案
     *
     * @param id
     */
    @DeleteMapping("/removeHealthRecord")
    public ApiResult removeHealthRecord(@RequestParam("id") Long id) {
        service.removeHealthRecord(id);
        return ApiResult.ok();
    }

    /**
     * 获取健康档案详情
     *
     * @param id
     * @return
     */
    @GetMapping("/getHealthRecord")
    public ApiResult<GetHealthRecordVo> getHealthRecord(@RequestParam("id") Long id) {
        GetHealthRecordVo vo = service.getHealthRecord(id);
        return ApiResult.ok(vo);
    }

    /**
     * 获取健康档案列表
     *
     * @param param
     * @return
     */
    @PostMapping("/getHealthRecordList")
    public ApiResult<PageResult<GetHealthRecordListVo>> getHealthRecordList(@RequestBody GetHealthRecordListParam param) {
        PageResult<GetHealthRecordListVo> result = service.getHealthRecordList(param);
        return ApiResult.ok(result);
    }



}

